package com.qingcloud.df.executor.enums;

/**
 * 组件运行方式枚举
 *
 * @author wangjinnan
 */
public enum ComponentRunModeEnum {

    /**
     * 独立式
     */
    ALONE(1,ComponentCommunicationEnum.AKKA),

    /**
     * 嵌入式
     */
    EMBED(2,ComponentCommunicationEnum.AKKA);

    /**
     * 类型编码
     */
    public final Integer code;

    /**
     * 通信方式
     */
    private final ComponentCommunicationEnum componentCommunicationEnum;


    ComponentRunModeEnum(int code,ComponentCommunicationEnum componentCommunicationEnum) {
        this.code = code;
        this.componentCommunicationEnum = componentCommunicationEnum;
    }
    public static ComponentRunModeEnum getByCode(Integer code){
        if(code==null){
            return null;
        }
        ComponentRunModeEnum[] values = ComponentRunModeEnum.values();
        for(ComponentRunModeEnum componentRunModeEnum : values){
            if(componentRunModeEnum.getCode().equals(code)){
                return componentRunModeEnum;
            }
        }
        return null;
    }


    public Integer getCode() {
        return code;
    }

    public ComponentCommunicationEnum getComponentCommunicationEnum() {
        return componentCommunicationEnum;
    }
}
